from tests.rypark_background.get_cookie import *
from common.config import *
import requests


class File:
    # 查询文件列表
    def file_list(self, env, fileNo=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/parkFile/list"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"fileNo": fileNo,
                "currentPage": 1,
                "pageSize": 10}
        return requests.post(url, headers=headers, json=dict).json()

    # 文件下载
    def down_file(self, env, fileNo):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/parkFile/download"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        return requests.get(url, headers=headers, params={"fileNo": fileNo}).json()

    # 文件删除
    def delete_file(self, env, fileNo):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/parkFile/delete"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        return requests.get(url, headers=headers, params={"fileNo": fileNo}).json()


